<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>报价方案年利率配置列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var grid = null;
	var _prpsCfgId;
	var annIntScale;
	$(function () {
		_prpsCfgId = '${prpsCfgId}';
		annIntScale = '${annIntScale}';
		var _url = '<%=path%>/project/prjQuatPrpsCfgAi/initList.do?prpsCfgId=' + _prpsCfgId ;
	    $("#ligergrid1").ligerGrid({
	    	url: _url,
	    	method : 'get',
	        columns: [
	            { display: '开始期数', name: 'stNum', width: 100, enabledSort:true },
	            { display: '结束期数', name: 'endNum', width: 100 , enabledSort:true},
	            { display: '租赁期数单位', name: 'lsPdUntCdNm', width: 100 , enabledSort:true},
	            { display: '年利率', name: 'annIntRatePct', width: 100 , enabledSort:true},
	            { display: '新能源年利率', name: 'annIntRatePct2', width: 100 , enabledSort:true},
	            { display: '是否允许变更', name: 'isAllowChgNm', width: 100 , enabledSort:true},
	            getColunmn()
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        rownumbers:true,
	        onAfterShowData: function () {
	            $( ".gridTip").grid_ligerTip();
	            SetIframe_height ();
	       }
	    });
	    grid = liger.get("ligergrid1");
	    grid.setHeight(100);
	    $("#searchBar").ligerForm();
	
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	    $("#clearBtn").click(function(event) {
	        $("#resetBtn").click();  //重置 input-text
	        var form = liger.get("searchBar");
	        form.setData({  //重置select等特殊表单
	            "brCd": " ",
	            "audStsCd": " "
	        });
	    });
	});
	
	function getColunmn(){
		return { display: '操作', width: 200 , align:'left',
        	render: function (rowdata, rowindex, value){
        		var h='<a class="sq-button-hasicon" href="javascript:toModify(';
	        		h+="'"+rowdata.id+"'";
	                h+=')"><i class="sqBtnIco_4"></i>修改</a>';
        		var g='<a class="sq-button-hasicon" href="javascript:deleteRecord(';
	        		g+="'"+rowdata.id+"'";
	                g+=')"><i class="sqBtnIco_4"></i>删除</a>';
            	return h+g;
        	}
        }
	}
	 //新增数据
	var callback = function () {
		grid.reload();
    };
	function add(){
        $.ligerDialog.open({
            width: 450,
            height:300,
            title : '新增年利率配置',
            url:'<%=path%>/project/prjQuatPrpsCfgAi/toAddPage.do?prpsCfgId='+_prpsCfgId+'&annIntScale='+annIntScale,
            buttons: [{
	                text: "保存", type: 'ok', cls: 'sq-button sq-button-round',
	                onclick: function (item, Dialog) {
	                    if (Dialog.onOk) Dialog.onOk();
	                }
	            }, {
	                text: "取消", type: 'cancel', cls: 'sq-button sq-button-round',
	                onclick: function (item, Dialog) {
	                    if (Dialog.onCancel) Dialog.onCancel();
	                }
	            }
	        ]
        });
	}
	
	 //修改数据
	function toModify(_id){
		if(!_id)return;
		$.ligerDialog.open({
            width: 450,
            height:300,
            title : '修改年利率配置',
            url:'<%=path%>/project/prjQuatPrpsCfgAi/toAddPage.do?id='+_id+'&annIntScale='+annIntScale,
            buttons: [{
	                text: "保存", type: 'ok', cls: 'sq-button sq-button-round',
	                onclick: function (item, Dialog) {
	                    if (Dialog.onOk) Dialog.onOk();
	                }
	            }, {
	                text: "取消", type: 'cancel', cls: 'sq-button sq-button-round',
	                onclick: function (item, Dialog) {
	                    if (Dialog.onCancel) Dialog.onCancel();
	                }
	            }
	        ]
        });
	}
	//删除数据
	function deleteRecord(_id){
		if(!_id)return;
		var _ids = [];
		_ids.push(_id);
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/project/prjQuatPrpsCfgAi/removeById.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
						 grid.reload();
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	
</script>

<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
            <div class="clearFix"></div>
            <div class="btnsBox">
                <span id="addBtn" class="sq-button sq-button-round" onclick="add();">新增</span>
            </div>
        </form>
    </div>
</div>
<div id="ligergrid1" class="sq-grid"></div>


</body>
</html>